//
//  LXGreenBeanButton.m
//  LvXi_newVersion
//
//  Created by 诸葛孔明 on 16/8/11.
//  Copyright © 2016年 SJT. All rights reserved.
//............................................................................................//
//......................................个人中心自定义按钮......................................//
//......................................上下都是文字.........................................//

#import "LXGreenBeanButton.h"

@interface LXGreenBeanButton ()


@end

@implementation LXGreenBeanButton

- (void)awakeFromNib
{
    [super awakeFromNib];
    UILabel *numberLabel = [[UILabel alloc] init];
    numberLabel.textColor = [UIColor greenColor];
    numberLabel.textAlignment = NSTextAlignmentCenter;
    numberLabel.font = [UIFont systemFontOfSize:14];
    
    self.numberLabel = numberLabel;
    [self addSubview:numberLabel];
    
    UILabel *nameLabel = [[UILabel alloc] init];
    numberLabel.textColor = [UIColor blackColor];
    nameLabel.textAlignment = NSTextAlignmentCenter;
    nameLabel.font = [UIFont systemFontOfSize:14];
    self.numberLabel.textColor = [UIColor colorWithRed:107 / 255.0 green:186 / 255.0 blue:77 / 255.0 alpha:1.0];
    
    self.nameLabel = nameLabel;
    [self addSubview:nameLabel];
    
    UIImageView *imageIcon = [[UIImageView alloc] init];
    self.imageIcon = imageIcon;
    [self addSubview:imageIcon];

}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
    UILabel *numberLabel = [[UILabel alloc] init];
    numberLabel.textColor = [UIColor greenColor];
    numberLabel.textAlignment = NSTextAlignmentCenter;
    numberLabel.font = [UIFont systemFontOfSize:14];
    self.numberLabel.textColor = [UIColor colorWithRed:107 / 255.0 green:186 / 255.0 blue:77 / 255.0 alpha:1.0];
    self.numberLabel = numberLabel;
    [self addSubview:numberLabel];
    
    UILabel *nameLabel = [[UILabel alloc] init];
    numberLabel.textColor = [UIColor blackColor];
    nameLabel.textAlignment = NSTextAlignmentCenter;
    nameLabel.font = [UIFont systemFontOfSize:14];
    self.nameLabel = nameLabel;
    [self addSubview:nameLabel];
        
    UIImageView *imageIcon = [[UIImageView alloc] init];
    self.imageIcon = imageIcon;
    [self addSubview:imageIcon];
        
    }
    
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.imageIcon.x = MineRatio(21);
    self.imageIcon.width = MineRatio(26);
    self.imageIcon.height = MineRatio(26);
    self.imageIcon.y = self.height * 0.5 - self.imageIcon.height * 0.5;
    
    self.nameLabel.x = self.imageIcon.right + MineRatio(6);
    self.nameLabel.width = [self.nameLabel.text sizeInAre:MaxSize font:self.nameLabel.font].width;
    self.nameLabel.height = [self.nameLabel.text sizeInAre:MaxSize font:self.nameLabel.font].height;
    self.nameLabel.y = self.height - self.nameLabel.height - MineRatio(8);
    
    self.numberLabel.x = self.nameLabel.x;
    self.numberLabel.width = self.nameLabel.width;
    self.numberLabel.height = [self.numberLabel.text sizeInAre:MaxSize font:self.numberLabel.font].height;
    self.numberLabel.y = self.nameLabel.y - self.numberLabel.height - MineRatio(3);
}

@end
